# -*- coding:utf-8 -*-
# author:zhou date:2019/5/10
import sys
import os
import django

sys.path.append("..")
sys.path.append("../utils")
os.environ.update({"DJANGO_SETTINGS_MODULE": "server.settings"})
django.setup()
from django.test import Client

client = Client()
headers = {'Content-Type': 'application/xml'}

baseUrl = u"http://127.0.0.1:8000/api/order/"


def orderList():
    # 管理人员
    # choice = '管理人员'
    # 开发人员
    # choice = '开发人员'
    # 使用人员
    choice = '使用人员'
    if choice == '管理人员':
        request = {
            'token': '61aa3da28253d3877c20',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0'
        }
    elif choice == '开发人员':
        request = {
            'token': '83764f261b574c03be2b',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0'
        }
    else:
        request = {
            'token': '80dd9bc3de1a768f6d41',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '1'
        }
    res = client.post(baseUrl + 'list/', request, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    print(res.content)


def orderDetail():
    # 管理人员
    # choice = '管理人员'
    # 开发人员
    # choice = '开发人员'
    # 使用人员
    choice = '使用人员'
    if choice == '管理人员':
        request = {
            'token': '61aa3da28253d3877c20',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0'
        }
    elif choice == '开发人员':
        request = {
            'token': '83764f261b574c03be2b',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0'
        }
    else:
        request = {
            'token': '80dd9bc3de1a768f6d41',
            'orderId': 1
        }
    res = client.post(baseUrl + 'detail/', request, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    print(res.content)


def orderDeal():
    # 管理人员
    choice = '管理人员'
    # 开发人员
    # choice = '开发人员'
    # 使用人员
    # choice = '使用人员'
    if choice == '管理人员':
        request = {
            'token': '61aa3da28253d3877c20',
            'orderId': 50,
            'option': 0,
            'status': '0',
            'result': '0'
        }
    elif choice == '开发人员':
        request = {
            'token': '61aa3da28253d3877c20',
            'orderId': 1,
            'option': 1,
            'status': '0',
            'result': '0'
        }
    else:
        request = {
            'token': '61aa3da28253d3877c20',
            'orderId': 50,
            'option': 3,
            'status': '2',
            'result': '0'
        }
    res = client.post(baseUrl + 'deal/', request, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    print(res.content)


def orderSearch():
    # 管理人员
    choice = '管理人员'
    # 开发人员
    # choice = '开发人员'
    # 使用人员
    # choice = '使用人员'
    if choice == '管理人员':
        request = {
            'token': '61aa3da28253d3877c20',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0',
            'warZoneId': '',
            'companyId': '',
            'softwareName': 'go'
        }
    elif choice == '开发人员':
        request = {
            'token': '83764f261b574c03be2b',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0',
            'warZoneId': '',
            'companyId': '',
            'softwareName': ''
        }
    else:
        request = {
            'token': '80dd9bc3de1a768f6d41',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0',
            'warZoneId': '',
            'companyId': '',
            'softwareName': ''
        }
    res = client.post(baseUrl + 'screen/', request, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    print(res.content)


def groupOrderList():
    # 管理人员
    # choice = '管理人员'
    # 开发人员
    # choice = '开发人员'
    # 使用人员
    choice = '使用人员'
    if choice == '管理人员':
        request = {
            'token': '61aa3da28253d3877c20',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0'
        }
    elif choice == '开发人员':
        request = {
            'token': '83764f261b574c03be2b',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0'
        }
    else:
        request = {
            'token': '61aa3da28253d3877c20',
            'page': 1,
            'maxItem': 1,
            'softwareGroup': '0'
        }
    res = client.post(baseUrl + 'groupList/', request, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    print(res.content)


if __name__ == '__main__':
    # orderList()
    # orderDetail()
    orderDeal()
    # orderSearch()
    # groupOrderList()
